<template>
    <div class="right">
      <el-breadcrumb separator="/" class="bread">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item><a href="/">权限管理</a></el-breadcrumb-item>
        <el-breadcrumb-item>权限列表</el-breadcrumb-item>
      </el-breadcrumb>
      <el-table
      :data="tableData"
      border
      style="width: 100%;">
      <el-table-column
        type="index"
        width="50">
      </el-table-column>
      <el-table-column
        prop="authName"
        label="权限名称">
      </el-table-column>
      <el-table-column
        prop="path"
        label="路径">
      </el-table-column>
      <el-table-column
        label="层级">
        <template slot-scope="scope">
          <span>{{scope.row.level | aa}}</span>
        </template>
      </el-table-column>
      </el-table>
    </div>
</template>
<script>
import { getRights } from '@/api'
export default {
  data () {
    return {
      tableData: []
    }
  },
  created () {
    this.initList()
  },
  filters: {
    aa: function (level) {
      if (level === '0') {
        return '一级'
      } else if (level === '1') {
        return '二级'
      } else {
        return '三级'
      }
    }
  },
  methods: {
    initList () {
      getRights('list')
        .then(res => {
          console.log(res)
          this.tableData = res.data.data
        })
    }
  }
}
</script>
<style lang="scss" scoped>
.bread {
  background-color: #F5F5F5;
  height: 45px;
  font-size: 15px;
  padding-left: 10px;
  line-height: 45px;
  margin-bottom: 15px;
}
</style>
